<template>
    <div class="homeWrapper">
        <div class="contentMain">
            <svg-icon name="hangzhouditiezhongxingTitle" class='icontitle'/>
            <headerRouter :status="status" @change="change" @changePaper="changePaper" :statusPaint="statusPaint"></headerRouter>
            <div class="electronPaintWrapper">
                <div class="statusWrapper">
                    <div v-if="statusPaint !== 2" class="status" v-for="(item,i) in status" :key="i">
                        <i v-if="item.value === true"><span class="circle_green"></span></i>
                        <i v-else><span class="circle_white"></span></i>
                        {{item.name}}
                    </div>
                    <div v-if="statusPaint !== 2" class="status"  v-for="(item,i) in light" :key="i">
                        <i v-if="item === 1"><span class="circle_green"></span></i>
                        <i v-else><span class="circle_white"></span></i>
                        {{i}}
                    </div>
                    <div v-if="statusPaint === 2" class="status"  v-for="(item,i) in locklight" :key="i">
                        <i v-if="item === 1"><span class="circle_green"></span></i>
                        <i v-else><span class="circle_white"></span></i>
                        {{i}}
                    </div>
                </div>
                <SvgMainPaint class="electronPaint" v-if="statusPaint === 1"></SvgMainPaint>
                <SvgEmergencyPaint class="electronPaint" v-if="statusPaint === 0"></SvgEmergencyPaint>
                <SvginnerLock class="electronPaint" v-if="statusPaint === 2"></SvginnerLock>
            </div>
        </div>
        <div class="asideright">
            <div class="titleTime">
                {{ dateTitle }}
            </div>
            <div class="detailWrapper">
                <h1>详情栏</h1>
                <main>
                    <span class="setQuestion">出题人:{{ examPeople }}</span>
                    <span>当前正在考试有<span class="underlineCount">{{ count }}</span>人</span>
                    <span>请输入答题人</span>
                    <span><button class="buttonAddPeople" @click="this.$alert('此功能正在研发！')">添加人员</button></span>
                    <span>
                        <span>工号</span>
                        <input/>
                    </span>
                    <span>
                        <span>姓名</span>
                        <input/>
                    </span>
                </main>
            </div>
            <Timer></Timer>
            <div class="operatehistory">
                <h1>操作</h1>
                <main class = "operate-box">
                    <router-view/>
                </main>
            </div>
        </div>
    </div>
</template>

<script setup>
//引入文件
import SvgMainPaint from '../components/SvgMainPaint.vue';
import Timer from "../components/Timer.vue";
import {computed, nextTick, onMounted, provide, reactive, ref} from "vue";
import dayjs from "dayjs";
import HeaderRouter from "@/components/headerRouter.vue";
import router from "../router";
import bus from "vue3-eventbus";
import {useStore} from "vuex";
import SvgEmergencyPaint from "../components/SvgEmergencyPaint.vue";
import SvginnerLock from "../components/SvginnerLock.vue";
const store = useStore();
//组件
components:{Timer};

let examPeople = ref('老陈')
let count = ref(1)
let electronPaint = ref(null)
//日历显示
let dateTitle = ref('2022-7-12  13:15:00')
setInterval(() => {
    dateTitle.value = dayjs().format("YYYY-MM-DD hh:mm:ss");
}, 1000)

let status = ref([
    {
        name:'练习模式',value:true
    },{
        name:'出题模式',value:false
    },{
        name:'考试模式',value:false
    }
])
// onMounted(()=>{
//     light.value =  store.state.global.relayStateAll
//     console.log('light.value->',light.value)
// })
let light
light = computed({
    get(){
        if(store.state.global.relayStateAll?.length !== 0 ){
            return store.state.global.relayStateAll
        }else{
            return { ZDBJ: 0, ZFBJ: 0, HADJ: 0, LUDJ: 0, GJ: 0, SJ: 0, UJ: 0, LJ: 0, YXJ: 0}
        }
    },
    set(value){
        console.log(value)
    }
})
let locklight = computed({
    get(){
        if(store.state.global.relayStateAll?.length !== 0 ){
            return store.state.global.relayStateAll
        }else{
            return {DBJ:0, LJ:0, FBJ:0, MJ:0, YXJ:0, GJ:0, UJ:0, HADJ:0, LUDJ:0, SJ:0}
        }
    },
    set(value){
        console.log(value)
    }
})
function change(command){
    status.value.forEach((item,i)=>{
        if(i === command){
            item.value = true
        }else{
            item.value = false
        }
    })
    switch (command) {
        case 0:
            router.push('/operate')
            bus.emit('reset')
            return;
        case 1:
            router.push('/operatetest')
            bus.emit('reset')
            return;
        case 2:
            router.push('/operatetask')
            bus.emit('reset')
            return;
    }
}

let statusPaint = ref(1)
function changePaper(command){
    console.log('command',command)
    statusPaint.value = command
    if(command === 2){
        router.push('/operateinnerlock')
    }else{
        router.push('/operate')
    }
}
</script>

<style lang="scss" scoped>
.homeWrapper {
    display: flex;
    flex-direction: row;
    justify-content: space-between;
    height: 100%;
    width: 100%;
    overflow: hidden;
    background-color: #081A3D;


    //左侧盒子
    .contentMain {
        //display: flex;

        width: calc(100vw - 428px);
        height: 100vh;
        //flex-direction: column;
        .icontitle {
            width: 400px;
            height: 80px;
        }
        .electronPaintWrapper {
            height: calc(100vh - 80px);
            overflow: hidden;
            position: relative;
            z-index: 0;
            border-radius: 10px;
            .statusWrapper{
                display:flex;
                flex-direction: row;
                justify-content: flex-start;
                align-items: center;
                .status{
                    display: flex;
                    flex-direction: row;
                    justify-content: center;
                    margin-top: 10px;
                    margin-left: 10px;
                    color: #ffffff;
                    .circle_green{

                        display: inline-block;
                        width: 20px;
                        height: 20px;
                        border-radius: 50%;
                        background:#1eed07;
                        animation: test 1000ms infinite;
                    }
                    @keyframes test {
                        from {
                            opacity: 1.0;
                        }
                        50% {
                            opacity: 0.4;
                        }
                        to {
                            opacity: 1.0;
                        }
                    }
                    .circle_white{
                        color: #ffffff;
                        display: inline-block;
                        width: 20px;
                        height: 20px;
                        border-radius: 50%;
                        background: #ffffff;
                    }
                }
            }
            &::before {
                content: '';
                position: absolute;
                z-index: -2;
                left: -50%;
                top: -50%;
                width: 200%;
                height: 200%;
                background-color: #1a232a;
                background-repeat: no-repeat;
                background-position: 0 0;
                background-image: conic-gradient(transparent, rgba(168, 239, 255, 1), transparent 30%);
                animation: rotate 4s linear infinite;
            }

            &::after {
                content: '';
                position: absolute;
                z-index: -1;
                left: 6px;
                top: 6px;
                width: calc(100% - 12px);
                height: calc(100% - 12px);
                background: #000000;
                border-radius: 5px;
            }

            @keyframes rotate {
                100% {
                    transform: rotate(1turn);
                }
            }

            .electronPaint {
                &::-webkit-scrollbar {
                    height: 0 !important;
                    width: 0 !important;
                    color: transparent !important;
                }

                overflow: auto;
            }
        }
    }

    .asideright {
        width: 428px;
        display: flex;
        justify-content: flex-start;
        align-items: center;
        flex-direction: column;
        background-color: #081A3D;
        height: 100%;
        .titleTime {
            text-align: center;
            color: #ffffff;
            font-size: 28px;
            width: 337px;
            height: 40px;
            border-radius: 12px;
            background-image: radial-gradient(circle, rgba(84, 188, 189, 0.57), rgba(84, 188, 188, 0.337));
        }
        .detailWrapper {
            h1 {
                color: #ffffff;
                font-size: 28px;
                font-weight: bold;
                font-style: italic
            }
            main {
                color: #ffffff;
                display: grid;
                grid-template-columns: 182.5px 182.5px;
                grid-template-rows: 43px 43px 43px;
                border-left: 1px solid rgba(187, 187, 187, 1);
                border-right: 1px solid rgba(187, 187, 187, 1);
                width: 365px;
                height: 218px;
                background-color: rgba(8, 26, 61, 1);
                .setQuestion {
                    color: rgba(207, 247, 96, 1);
                    font-size: 18px;
                    font-weight: bolder;
                    font-style: italic
                }
                .underlineCount {
                    color: #1eed07;
                    text-decoration: underline;
                }
                .buttonAddPeople {
                    padding: 5px;
                    border: none;
                    color: #ffffff;
                    background: blueviolet;
                    border-radius: 5px;
                }
                input {
                    width: 135px;
                    border-radius: 5px;
                }
            }
        }
        .operatehistory {
            height: calc( 100% - 560px );
            h1 {
                color: #ffffff;
                font-size: 28px;
                font-weight: bold;
                font-style: italic
            }
            main {
                border-left: 1px solid rgba(187, 187, 187, 1);
                border-right: 1px solid rgba(187, 187, 187, 1);
                width: 365px;
                background-color: rgba(8, 26, 61, 1);
                height: calc(100% - 28px);
            }
        }
    }
}
</style>
